﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;

namespace RescueRaiders
{
    namespace Particles
    {
        class PlumeParticleSystem : ParticleSystem
        {
            public PlumeParticleSystem(Game1 game,
                int howManyEffects, string textureFileName) :
                base(game, howManyEffects, textureFileName)
            {
            }

            protected override void InitializeConstats()
            {
               
                minInitialSpeed = 20;
                maxInitialSpeed = 100;

                minAcceleration = 0;
                maxAcceleration = 0;

                minLifeTime = 1.0f;
                maxLifeTime = 3.0f;

                minScale = 0.05f;
                maxScale = 0.1f;

                minNumParticles = 7;
                maxNumParticles = 15;

                minRotationSpeed = -MathHelper.PiOver4 / 2.0f;
                maxRotationSpeed = MathHelper.PiOver4 / 2.0f;

                spriteBlendMode = SpriteBlendMode.AlphaBlend;

                DrawOrder = AlphaBlendDrawOrder;

                
            }

        /// <summary>
        /// PickRandomDirection is overriden so that we can make the particles always 
        /// move have an initial velocity pointing up.
        /// </summary>
        /// <returns>a random direction which points basically up.</returns>
            protected override Vector2 PickRandomDirection()
            {
                // Point the particles somewhere between 80 and 100 degrees.
                // tweak this to make the smoke have more or less spread.
                float radians = ParticleSystem.RandomBetween(
                    MathHelper.ToRadians(80), MathHelper.ToRadians(100));

                Vector2 direction = Vector2.Zero;
                // from the unit circle, cosine is the x coordinate and sine is the
                // y coordinate. We're negating y because on the screen increasing y moves
                // down the monitor.
                direction.X = (float)Math.Cos(radians);
                direction.Y = -(float)Math.Sin(radians);
                return direction;
            }

        /// <summary>
        /// InitializeParticle is overridden to add the appearance of wind or movement.
        /// </summary>
        /// <param name="p">the particle to set up</param>
        /// <param name="where">where the particle should be placed</param>
            protected override void InitializeParticle(Particle p, Vector2 where, Vector2 towhere, float unitscale)
        {
            base.InitializeParticle(p, where, towhere, unitscale);

            // the base is mostly good, but we want to simulate a little bit of wind
            // heading to the right.

            p.acceleration.X += ParticleSystem.RandomBetween(-5, 5);
            }
        }
    }
}


